﻿<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<p style="text-align: left;"><img class="aligncenter size-full wp-image-153" title="msesta" src="http://incoming.blueink.org/blog/wp-content/uploads/2009/03/msesta.gif" alt="msesta" width="152" height="40"></p>
<form name="regform" id="regform" method="get">
    请输入搜索字符，以空格区分：<input type="text" size=30 name="kw" value="">
    <input type="submit" value="搜索" name="btnSubmit">
</form>

<?php



//1使用方法：用ftplist软件生成站点文件列表，注意要选中显示文件、使用中文、包含用户名和密码
//2点击url，然后点击保存，命名为url.txt，保存于与本文件相同的路径下
//3在下面输入ftp站点名，格式ftp://user:pass@addr:port/，注意前面的ftp://和结尾的一个/不要省略!!!

$ftpsite='ftp://mse:kexie@incoming.blueink.org:40021/';  //定制站点行



$ftp_len=strlen($ftpsite);
$keyword=mb_convert_encoding(htmlspecialchars($_GET[kw]),"GBK","UTF-8");
if ($_GET[kw]!=""){
if(	substr_count($keyword,"\\")||substr_count($keyword,"/")||substr_count($keyword,":")||
	substr_count($keyword,"*") ||substr_count($keyword,"?")||substr_count($keyword,htmlspecialchars("\""))||
	substr_count($keyword,htmlspecialchars('<'))           ||substr_count($keyword,htmlspecialchars('>')) || 
	substr_count($keyword,"?")	) echo "输入非法字符！";
else { //if(输入非法字符！)
if (count!="") $kwd=explode(" ",$keyword,8);
echo "您输入的搜索字串是：";for ($i=0;$i<=count($kwd)-1;$i++) echo mb_convert_encoding($kwd[$i],"UTF-8","GBK")." ";

$st=0;  //显示禁止超过200条
$file_handle = fopen("url.txt", "r");
$url = fgets($file_handle);
while (!feof($file_handle)) {
   for ($i=0;$i<=count($kwd)-1;$i++) {
	if ($kwd[$i]!=""&&(!stripos($url,$kwd[$i],$ftp_len))) break;
	}
   if ($i==count($kwd)) {
	for ($i=0;$i<=count($kwd)-1;$i++) {
	if ($kwd[$i]!=""&&(!mb_stripos($url,$kwd[$i],$ftp_len,"GBK"))) break;
	}
	if ($i==count($kwd)) {
		$st++;$urlG=mb_convert_encoding($url,"UTF-8","GBK");
		echo "<br>".$st.". <a href=".$ftpsite.rawurlencode(mb_convert_encoding(substr($urlG,$ftp_len,strrpos($urlG,"/")-$ftp_len+1),"GBK","UTF-8")).' target="_blank">'.substr($urlG,$ftp_len)."</a><br>";
		}
	}
   if ($st==200) {echo "<br>下面还有喔，但检索到的条目太多，请改进关键词";break;}
   $url = fgets($file_handle);
   }
if ($st==0) echo "<br>居然没有找到！改变关键词试试？";

echo "<br>搜索成功完成";
}//else (输入非法字符！)
}
echo "<br>Incoming.blueink.org FTP Search Engine v0.23. Report bugs to writer greenleaf6[At]sina.com";
?>